import threading
import time


def task1():
    for i in range(5):
        print("Task 1 is running")
        time.sleep(1)


def task2():
    for i in range(5):
        print("Task 2 is running")
        time.sleep(1)


# 创建两个线程
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)

# 启动线程
thread1.start()
thread2.start()

# 主线程等待线程1和线程2执行完成
thread1.join()
thread2.join()

print("Both tasks are done")
